#include "ScnsAp3216c.h"

#if defined(SCNS_AP3216C_ENABLE)&&SCNS_AP3216C_ENABLE==1

#include "ScnsIic.h"
#include "ScnsMenu.h"
#include "ScnsSmctpExtOscilloscope.h"

ScnsStatus scnsBspAp3216cPostInit(ScnsAp3216cEnum ap3N)
{
    scnsMenuSetPage(1,"Ap3216c",NULL);
    scnsMenuAddConstStruct(1,scnsAp3216cResult[ap3N],ir,,SCNS_TYPE_UINT16);
    scnsMenuAddConstStruct(1,scnsAp3216cResult[ap3N],ps,,SCNS_TYPE_UINT16);
    scnsMenuAddConstStruct(1,scnsAp3216cResult[ap3N],als,,SCNS_TYPE_UINT16);
    return SCNS_STATUS_OK;
}

static const uint8 device[SCNS_AP3216C_MAX]={0X3C};

ScnsStatus scnsBspAp3216cWrite(ScnsAp3216cEnum ap3N,const uint8*addr,uint8 addrLen,const uint8*data,uint8 dataLen)
{
    return scnsIicWriteTick(SCNS_IIC_SOFT_1,device[ap3N],addr,addrLen,data,dataLen,4);
}

ScnsStatus scnsBspAp3216cRead(ScnsAp3216cEnum ap3N,const uint8*addr,uint8 addrLen,uint8*data,uint8 dataLen)
{
    return scnsIicReadTick(SCNS_IIC_SOFT_1,device[ap3N],addr,addrLen,data,dataLen,4);
}

void scnsBspAp3216cResultUpdate(ScnsAp3216cEnum ap3N)
{
    if(scnsMenuCanPageSend(1))
    {
        scnsSmctpExtOscilloscopeSendFloat(
            SCNS_SMCTP_CHANNEL_VISUAL_SCOPE,0,
            scnsAp3216cResult[SCNS_AP3216C_1].ir,
            scnsAp3216cResult[SCNS_AP3216C_1].ps,
            scnsAp3216cResult[SCNS_AP3216C_1].als
        );
    }
}

#endif
